package structure.tree;

public class BinaryTreeNode {
    private String name;
    private BinaryTreeNode leftChild;
    private BinaryTreeNode rightChild;
    /** 节点是否可用 */
    private boolean enabled;
    /** 节点是否已读 */
    private boolean read;

    public String getName() {
        return name;
    }

    public BinaryTreeNode getLeftChild() {
        return leftChild;
    }

    public void setLeftChild(BinaryTreeNode leftChild) {
        this.leftChild = leftChild;
    }

    public BinaryTreeNode getRightChild() {
        return rightChild;
    }

    public void setRightChild(BinaryTreeNode rightChild) {
        this.rightChild = rightChild;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        if (this.enabled && !enabled) {
            this.enabled = false;
        } else if (!this.enabled && enabled) {
            this.enabled = true;
        }
    }

    public boolean isRead() {
        return read;
    }

    public void setRead(boolean read) {
        if (this.isRead() && !read) {
            this.read = false;
        } else if (!this.isRead() && read) {
            this.read = true;
        }
    }

    public BinaryTreeNode(String name) {
        this.name = name;
        leftChild = null;
        rightChild = null;
        enabled = true;
        read = false;
    }
}
